<?php
class View_out extends View {
    public function add_title($title) {
        $title = trim($title);
        if (empty($title)) {
            return;
        }
        
        if ( ! isset($this->data['title'])) {
            $this->data['title'] = $title;
        } else {
            $this->data['title'] .= ' - ' . $title;
        }
    }
    
    
    public function add_keywords($keywords) {
        $keywords = trim($keywords);
        if (empty($keywords)) {
            return;
        }
        
        if ( ! isset($this->data['keywords'])) {
            $this->data['keywords'] = $keywords;
        } else {
            $this->data['keywords'] .= ', ' . $keywords;
        }
    }
    
    
    public function add_description($description) {
        $description = trim($description);
        if (empty($description)) {
            return;
        }
        
        if ( ! isset($this->data['description'])) {
            $this->data['description'] = $description;
        } else {
            $this->data['description'] .= '; ' . $description;
        }
    }
    
    
    public function add_js($js) {
        $js = trim($js);
        if (empty($js)) {
            return;
        }
        
        if ( ! isset($this->data['js'])) {
            $this->data['js'] = array();
        }
        $this->data['js'][] = "<script type=\"text/javascript\" src=\"{$js}\"></script>";
    }
    
    
    public function add_js_script($block_script) {
        $this->add_block($block, 'js_script');
    }
    
    
    public function add_prejs($js) {
        $js = trim($js);
        if (empty($js)) {
            return;
        }
        
        if ( ! isset($this->data['prejs'])) {
            $this->data['prejs'] = array();
        }
        $this->data['prejs'][] = "<script type=\"text/javascript\" src=\"{$js}\"></script>";
    }
    
    
    public function add_prejs_script($block_script) {
        $this->add_block($block_script, 'prejs_script');
    }
    
    public function add_css($css) {
        $css = trim($css);
        if (empty($css)) {
            return;
        }
        
        if ( ! isset($this->data['css'])) {
            $this->data['css'] = array();
        }
        
        $this->data['css'][] = "<link rel=\"stylesheet\" href=\"{$css}\" type=\"text/css\" />";
    }
}
?>